var http = require("http");
const path = require("path");
const fs = require("fs");
const { Readable } = require("stream");

var filePath = path.join(__dirname,"/data.txt");
var readable = fs.createReadStream(filePath);

http.createServer((reg,res)=>{
    readable.on("data",function(chunk){
        res.end(chunk.toString("utf-8"));
    
    })
    readable.on("end",function(){
        console.log("   readable ended");
    })
    
    readable.pipe(process.stdout);   
     
}).listen(8081);